package com.shenfc.fxzj.constants;

import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public enum OauthTypeEnum {

    QQ("1", "QQ");
    private String key;
    private String value;

    OauthTypeEnum(String key, String value) {
        this.key = key;
        this.value = value;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public static String getValue(String key) {
        if(StringUtils.isBlank(key)){
            return "";
        }
        for (OauthTypeEnum e : OauthTypeEnum.values()) {
            if (key != null && e.getKey().equals(key)) {
                return e.getValue();
            }
        }
        return "";
    }

    public static List<Map<String, String>> getList() {
        List<Map<String, String>> list = new ArrayList<Map<String, String>>();
        for (OauthTypeEnum e : OauthTypeEnum.values()) {
            Map<String, String> map = new HashMap<String, String>();
            map.put("key", e.getKey());
            map.put("value", e.getValue());
            list.add(map);
        }
        return list;
    }
}
